package com.objetdirect.gwt.umldrawer.server.services;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.objetdirect.gwt.umldrawer.server.dao.ProfilePictureDao;
import com.objetdirect.gwt.umldrawer.shared.dto.DeveloperDto;
import com.objetdirect.gwt.umldrawer.shared.dto.ProfilePictureDto;
import com.objetdirect.gwt.umldrawer.shared.services.ProfilePictureService;

@Service("profilePictureService")
public class ProfilePictureServiceImpl implements ProfilePictureService {

	@Autowired
	private ProfilePictureDao profilePictureDao;

	@PostConstruct
	public void init() throws Exception {
	}

	@PreDestroy
	public void distroy() {
	}

	@Override
	@Transactional (propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public void uploadProfilePicture(String developerEmail, String picturePath)
			throws Exception {
		
		DeveloperDto developer = new DeveloperDto(developerEmail);
		ProfilePictureDto profilePicture = new ProfilePictureDto(picturePath, developer);
		profilePictureDao.persist(profilePicture);
	}

	@Override
	@Transactional (propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public String getProfilePicturePath(String developerEmail) throws Exception {
		
		return null;
	}


}
